package plgbasev0

import (
	"dgo/goutils/utils"
)

const (
	PLUG_DISP_RELEASE string = "/plug/release"
	PLUG_DISP_CHANGED string = "plug/changed"
)

/*
*

	将外面的ID设置进去,让插件知道自己的ID
*/
type IPlugin_SetID interface {
	SetPlugID(val string)
}

type IPlugin_IsRelease interface {
	IsRelease() bool
}

func PluginIsRelease(v interface{}) int {
	if intf, ok := v.(IPlugin_IsRelease); ok {
		if intf.IsRelease() {
			return 1
		} else {
			return 0
		}
	} else {
		return -1
	}
}

func TrySetPlugID(obj interface{}, val string) bool {
	if intf, ok := obj.(IPlugin_SetID); ok {
		intf.SetPlugID(val)
		return true
	}
	return false
}

type IGetSubscriber interface {
	GetSubscriber() *utils.SubscribeCenter
}

type ISendKVs interface {
	SendKVs(topic string, kv ...interface{}) error
}

type IDispatchData interface {
	DispatchData(channelid string, sender interface{}, data interface{}, tag interface{}) (err error)
}
